/**
 * Created by liubin on 2014/11/28.
 */
define(['user/module'], function (module) {

    'use strict';

    module.registerController('UserAddCtrl', function ($scope, $state, $log, NotificationService, UserList) {
        $log.log('UserAddCtrl');
        $scope.save = function () {
            $log.log('start add');
            if ($('#add-form').valid()) {
                UserList.post(
                    //args参数
                    {},
                    //POST参数
                    {
                        name: $scope.user.name,
                        pwd: $scope.user.pwd,
                        real_name: $scope.user.realName
                    },
                    function (success) {
                        //$log
                        //if (success.success) {
                            // 更新成功
                        $state.go('app.user.list');
                        //} else {
                        //    NotificationService.warning("错误", success.messages[0]);
                        //}
                    }
                );
            }
        }
        $scope.back = function(){
            $state.go('app.user.list');
        }
    });
});